package s

import (
	"log"
	"sync"
)

var (
	ErrStack = List[error]{}
	rw       = sync.RWMutex{}
)

func IfErrWillFatal() {
	if ErrStack.Len() > 0 {
		log.Fatal(SafePop(&ErrStack))
	}
}

func SafePushErr(err error) {
	SafePush(&ErrStack, err)
}

func SafePopErr() (err error) {
	return SafePop(&ErrStack)
}
